﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace 论文信息管理软件
{
    public partial class AddForm : Form
    {
        private DataSet PaperDt;
        public AddForm(DataSet Dt)
        {
            InitializeComponent();
            PaperDt = Dt;
            int n = PaperDt.Tables[0].Rows.Count;
            this.lbNumber.Text = Convert.ToString(n + 1);
        }
        public AddForm()
        {
            InitializeComponent();
        }
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (textTitle.Text == "")
            {
                MessageBox.Show("对不起，标题不能为空！","警告");
                return;
            }
            DataRow newRow = PaperDt.Tables[0].NewRow();
            newRow[0] = this.lbNumber.Text;
            newRow[1] = this.textTitle.Text;
            newRow[2] = this.textAuthor.Text;
            newRow[3] = this.textKeyWords.Text;
            newRow[4] = this.textAbstract.Text;
            PaperDt.Tables[0].Rows.Add(newRow);
            PaperDt.WriteXml(@"论文信息");
            MessageBox.Show("添加成功！", "提醒");
            this.Close();
        }

        private void btnCancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
